
package com.ly.credit.controller;

import com.ly.credit.service.ApiService;
import com.ly.credit.service.UserService;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;


/**
 * 在线设计功能相关类
 */
@Controller
public class ApiController {
	@Resource
	private HttpServletRequest request;
	@Resource
	private UserService userService;
	@Resource
	private ApiService apiService;


	@RequestMapping("/getApiData.do")
	@ResponseBody
	public JSONObject getApiData(
			@RequestParam(required = true, value = "phone") String phone,
			@RequestParam(required = true, value = "appkey") String appkey,
			@RequestParam(required = true, value = "account") String account,
			@RequestParam(required = true, value = "apiValue") Integer apiValue,
			@RequestParam(required = true, value = "password") String password
	) {
		JSONObject json = apiService.getApiData(phone, appkey, account, apiValue, password);
		return json;

	}

	@RequestMapping("/getApiDataVerify.do")
	@ResponseBody
	public JSONObject getApiDataVerify(
			@RequestParam(required = true, value = "phone") String phone,
			@RequestParam(required = true, value = "appkey") String appkey,
			@RequestParam(required = true, value = "account") String account,
			@RequestParam(required = true, value = "apiValue") Integer apiValue,
			@RequestParam(required = true, value = "verifycode") String verifycode
	) {
		JSONObject json = apiService.getApiDataVerify(phone, appkey, account, apiValue, verifycode);
		return json;

	}

	@RequestMapping("/getVerify.do")
	@ResponseBody
	public JSONObject getVerify(
			@RequestParam(required = true, value = "phone") String phone) {

		JSONObject json = apiService.getVerify(phone);
		return json;

	}
}